package com.coocaa.ops.admin.v1.device.converter;

import com.coocaa.ops.admin.base.language.CommonLanguageProperties;
import com.coocaa.ops.common.core.biz.device.entity.GlobalDeviceInfoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * @author bijiahao
 * @description
 * @date 2020/1/6 17:21
 */
@Component
public class DeviceSaveConverter {
    private static CommonLanguageProperties commonLanguageProperties;

    public static void handleTrim(GlobalDeviceInfoEntity entity) {
        Assert.hasText(entity.getChip(), commonLanguageProperties.getChip() + commonLanguageProperties.getNotNull());
        Assert.hasText(entity.getModel(), commonLanguageProperties.getModel() + commonLanguageProperties.getNotNull());
        entity.setChip(entity.getChip().trim());
        entity.setModel(entity.getModel().trim());
    }

    @Autowired
    public void setCommonLanguageProperties(CommonLanguageProperties commonLanguageProperties) {
        DeviceSaveConverter.commonLanguageProperties = commonLanguageProperties;
    }

}
